<!--
 * @FilePath     : /study_code/layui/17-14.html
 * @Description  : position：设置定位方式。日期时间选择控件直接嵌入 #test2 容器中
 * @Date         : 2025-04-10 10:31:32
 * @Author       : Fang YingGui
 * @LastEditors  : fangyinggui 18715384437@163.com
 * @LastEditTime : 2025-04-10 10:31:42
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentName</title>
    <link rel="stylesheet" href="/layui/dist/css/layui.css" />
  </head>
  <body>
    <span id="testView"></span>

    <hr />
    <!-- 日期时间选择控件直接嵌入 #test2 容器中 -->
    <div id="test2"></div>

    <script src="/layui/dist/layui.js"></script>
    <script>
      layui.use(['laydate'], function () {
        var laydate = layui.laydate,
          $ = layui.$
        //默认显示

        //嵌套在指定容器中
        laydate.render({
          elem: '#test2',
          position: 'static',
          change: function (value, date) {
            //监听日期被切换
            $('#testView').html(value) // 赋选中日期值
          },
        })
      })
    </script>
  </body>
</html>
